<template>
  <div class="container">
    <div class="header">
      <div class="left">
        <nuxt-link to="/"></nuxt-link>
        <span>&nbsp;·&nbsp;</span>
        <span>选科</span>
      </div>
      <div class="right">
        <avatar></avatar>
      </div>
    </div>
    <div class="main-wrap">
      <div class="aside-wrap">
        <div class="nav-wrap">
          <div>
            <span :class="activeIndex===0&&'active'"></span>
            <nuxt-link :to="{name:'xuanke'}" tag="a" :class="activeIndex===0&&'active'">
              智能选科
            </nuxt-link>
          </div>
          <div>
            <span :class="activeIndex===1&&'active'"></span>
            <nuxt-link :to="{name:'xuanke-by-profession'}" tag="a" :class="activeIndex===1&&'active'">
              按专业选科目
            </nuxt-link>
          </div>
          <div>
            <span :class="activeIndex===2&&'active'"></span>
            <nuxt-link :to="{name:'xuanke-by-subject',params:{isFirst:true}}" tag="a" :class="activeIndex===2&&'active'">
              按科目选专业
            </nuxt-link>
          </div>
          <div>
            <span :class="activeIndex===3&&'active'"></span>
            <nuxt-link :to="{name:'xuanke-search'}" tag="a" :class="activeIndex===3&&'active'">
              搜索
            </nuxt-link>
          </div>
        </div>
      </div>
      <div class="main">
        <div class="nuxt-wrap" :class="isPlus?'active':''">
          <nuxt/>
          <!-- <keep-alive>
            <nuxt v-if="$route.meta.keepAlive"/>
          </keep-alive>
          <nuxt v-if="!$route.meta.keepAlive"/> -->
        </div>
      </div>
    </div>
    <top-btn></top-btn>
  </div>
</template>

<script>
export default {
  data () {
    return {
      isPlus: false,
      isShow: false
    }
  },
  computed: {
    activeIndex () {
      const pathsFirst = ['xuanke', 'xuanke-holland', 'xuanke-report']
      if (pathsFirst.indexOf(this.$route.name) > -1) {
        return 0
      }
      const pathSecond = ['xuanke-by-profession']
      if (pathSecond.indexOf(this.$route.name) > -1) {
        return 1
      }
      const pathThird = ['xuanke-by-subject']
      if (pathThird.indexOf(this.$route.name) > -1) {
        return 2
      }
      const pathfouth = ['xuanke-search', 'xuanke-profession-details']
      if (pathfouth.indexOf(this.$route.name) > -1) {
        return 3
      }
      switch (this.$route.query.fromPage) {
        case 'report':
          return 0
        case 'by-profession':
          return 1
        case 'by-subject':
          return 2
        case 'search':
          return 3
        default:
          return 4
      }
    }
  }
  // mounted () {
  //   console.log('屏幕宽度为：' + document.documentElement.clientWidth + this.isPlus)
  //   window.onresize = function () {
  //     if (document.documentElement.clientWidth > 1300) {
  //       this.isPlus = true
  //     } else {
  //       this.isPlus = false
  //     }
  //   }
  //   if (document.documentElement.clientWidth > 1300) {
  //     this.isPlus = true
  //   } else {
  //     this.isPlus = false
  //   }
  // }
}
</script>
<style scoped lang="scss">
$header_height: 50px;
.container {
  min-height: 100%;
  height: auto;
  background: $grey;
  display: flex;
  flex-direction: column;
  .header {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    height: $header_height;
    width: 100%;
    padding: 0 60px;
    // background: linear-gradient(270deg, $yellow 0%, $dark_yellow 100%);
    background-color: $light;
    color: $light;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px 0 $stable;
    .left {
      display: flex;
      align-items: center;
      > a {
        background: url("https://fdwebhost.oss-cn-huhehaote.aliyuncs.com/zhiyazhiyuan/images/logo.png") center no-repeat;
        background-size: cover;
        text-align: left;
        width: 72px;
        height: 25px;
        display: inline-block;
      }
      span {
        margin-top: -2px;
        color: $dark;
        font-size: 22px;
        // letter-spacing: 2px;
        font-weight: 300;
      }
      .icon-logo {
        color: $light;
        margin-right: 10px;
        font-size: 22px;
      }
    }
    .right {
      position: relative;
      cursor: pointer;
      display: flex;
      align-items: center;
      > a {
        color: $dark;
        padding-right: 10px;
        letter-spacing: 1px;
        line-height: 35px;
        &:hover,
        &:focus {
          color: $energized !important;
          text-decoration: none !important;
          background: none !important;
        }
      }
      /deep/ .avatar .icon{
        color: black;
      }
    }
  }
  .main-wrap {
    // border: 1px solid red;
    min-height: 100%;
    height: auto;
    flex: 1;
    display: flex;
    // overflow: hidden;
    margin-top: $header_height;
    .aside-wrap {
      position: fixed;
      top: $header_height;
      bottom: 0;
      left: 0;
      right: 180px;
      width: 180px;
      height: 100%;
      background: $light;
      z-index: 900;
      .nav-wrap {
        padding: 30px 14px;
        div {
          display: flex;
          justify-content: flex-end;
          align-items: center;
          margin-bottom: 20px;
          a {
            color: $dark;
            display: block;
            font-size: $size16;
            &.active {
              color: $energized;
            }
          }
          span {
            &.active {
              content: "";
              position: relative;
              display: block;
              width: 20px;
              height: 20px;
              margin-right: 10px;
              background: $energized;
              border-radius: 5px;
              left: 0;
              &::after {
                content: "";
                position: absolute;
                width: 0;
                height: 0;
                bottom: -5px;
                left: 50%;
                border-right: 5px solid transparent;
                border-top: 6px solid $energized;
                border-left: 5px solid transparent;
                transform: translate(-50%, 0);
              }
            }
          }
        }
      }
    }
    .main {
      height: auto;
      min-height: 100%;
      margin-left: 180px;
      padding: 60px;
      flex: 1;
      // overflow-y: auto;
      .nuxt-wrap {
        &.active {
          width: 1200px;
          margin: 0 auto;
        }
        position: relative;
        background: $light;
        min-height: 100%;
        padding: 37px 75px;
        // overflow-y: auto;
        box-sizing: border-box;
        // overflow: hidden;
      }
    }
  }
}
</style>
